package com.mymoney.utils;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

public class ServiceUtils {

	/**
	 * 
	 * @param code
	 * @param message
	 * @return
	 */
	public static Response getErrorResponse(int code, Exception e) {
		e.printStackTrace();
		
		return Response.status(code).entity("ERROR 111").type(MediaType.APPLICATION_JSON).build();
	}

	/**
	 * 
	 * @param request
	 * @return
	 */
	public static String getBaseURL(javax.servlet.http.HttpServletRequest request) {

		StringBuilder url = new StringBuilder();
		url.append(request.getScheme()).append("://");
		url.append(request.getServerName());
		int serverPort = request.getServerPort();
		if (serverPort != 80) {
			url.append(":").append(serverPort);
		}
		url.append(request.getContextPath());
		return url.toString();
	}

	/**
	 * 
	 * @param id
	 * @param message
	 * @return
	 */
	public static String getStatusBean(String id, String message) {

		return Response.Status.OK.getStatusCode() + " EVALAAAA";
	}

}
